package com.ruoyi.mp.convert;

import cn.hutool.core.bean.BeanUtil;
import com.ruoyi.mp.domain.MpMaterial;
import com.ruoyi.mp.domain.vo.material.MpMaterialUploadRespVO;
import me.chanjar.weixin.mp.bean.material.WxMpMaterial;

import java.io.File;


public interface MpMaterialConvert {

    static MpMaterial convert(String mediaId, String type, String url,
                              String name){
        MpMaterial mpMaterial = new MpMaterial();
        mpMaterial.setName(name);
        mpMaterial.setMediaId(mediaId);
        mpMaterial.setType(type);
        mpMaterial.setUrl(url);
        return mpMaterial;
    }

    static MpMaterial convert(String mediaId, String type, String url,
                         String name, String title, String introduction, String mpUrl){
        MpMaterial mpMaterial = new MpMaterial();
        mpMaterial.setName(name);
        mpMaterial.setMediaId(mediaId);
        mpMaterial.setType(type);
        mpMaterial.setUrl(url);
        mpMaterial.setTitle(title);
        mpMaterial.setIntroduction(introduction);
        mpMaterial.setMpUrl(mpUrl);
        return mpMaterial;
    }

    static MpMaterialUploadRespVO convert(MpMaterial bean){
        return BeanUtil.copyProperties(bean,MpMaterialUploadRespVO.class);
    }

    static WxMpMaterial convert(String name, File file, String title, String introduction) {
        return new WxMpMaterial(name, file, title, introduction);
    }

}
